package com.zwz.service.impl;

import com.zwz.entity.EnterpriseInfo;
import com.zwz.entity.InvestmentEmploymentInfo;
import com.zwz.mapper.InvestmentEmploymentMapper;
import com.zwz.service.InvestmentEmploymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

@Service
@Transactional
public class InvestmentEmploymentServiceImpl implements InvestmentEmploymentService {

    @Autowired
    private InvestmentEmploymentMapper mapper;

    @Override
    public void create(InvestmentEmploymentInfo info) {

        // 创建主表记录
        EnterpriseInfo enterpriseInfo=new EnterpriseInfo();
        enterpriseInfo.setId(Long.valueOf(info.getEnterpriseId()));
        //最后关联上
        info.setEnterpriseId(Math.toIntExact(enterpriseInfo.getId()));
        mapper.insert(info);
    }

    @Override
    public InvestmentEmploymentInfo getById(Integer id) {
        return mapper.selectById(id);
    }

    @Override
    public void update(InvestmentEmploymentInfo info) {
        mapper.update(info);
    }

    @Override
    public void deleteById(Integer id) {
        mapper.deleteById(id);
    }

    @Override
    public List<InvestmentEmploymentInfo> getAll() {
        return mapper.selectAll();
    }
}